<template>
  <BaseQuery>
    <BaseQueryLeft :span="2">
      <el-button icon="el-icon-plus" size="small" type="primary" @click="add">
        新增团队
      </el-button>
    </BaseQueryLeft>
    <BaseQueryRight :span="22">
      <el-form :model="form" :inline="true" size="small">
        <el-form-item label="门店:">
          <el-select v-model="form.shopId" clearable placeholder="请选择">
            <el-option v-for="item in allShopList" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="search">查询</el-button>
        </el-form-item>
      </el-form>
    </BaseQueryRight>
  </BaseQuery>
</template>

<script>
import { broadcast } from "@/utils/util";
export default {
  name: "QueryForm",
  props: {
    value: {
      type: Object,
      default: () => {},
    },
    shopList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      form: {},
    };
  },
  computed: {
    allShopList() {
      return [
        {
          value: "",
          label: "全部门店",
        },
        ...this.shopList,
      ];
    },
  },
  watch: {
    value: {
      handler(val) {
        this.form = val;
      },
      deep: true,
      immediate: true,
    },
    form: {
      handler(val) {
        this.$emit("input", val);
      },
      deep: true,
    },
  },
  methods: {
    search() {
      this.$parent.page.page = 1;
      this.$emit("search");
    },
    add() {
      //this.$router.push({ name: "TeamCreate", params: { type: "add" } });
       broadcast("look.user.team", { type: "add" });
    },
  },
};
</script>
